package com.fe.util;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

public class PageBean {
    public static Map<String , Object> serverMap(Map<String , Object> map,Object obj,Integer pages){
        //获取obj的类名
        String t = obj.getClass().getSimpleName();
        //将类名全部转为小写
        String type = t.toLowerCase();
        map.put(type , obj);
        //record mapper.xml中根据他进行选择从哪开始显示
        map.put("record" , (pages-1)*12);
        return map;
    }
    public static Map<String , Object> map(Map<String , Object> map,Integer pages,HttpServletRequest request){
    	int count = 1;
        if (map.get("count") != null) {
            count = Integer.parseInt(map.get("count").toString());
            if (count == 0) {
                count = 1;
            }
        }
        int sumPage = (count%12==0)?(count/12):(count/12+1);
        map.put("pages" , pages);
        map.put("sumPage" , sumPage);
        map.put("url" , request.getServletPath());
        return map;
    }
}
